/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.ResultSet;
import java.util.ArrayList;
import pojo.LoaiTinPoJo;
import util.DataProvider;
import java.sql.SQLException;

/**
 *
 * @author Kanet
 */
public class LoaiTinDao {
        
    public static ArrayList<LoaiTinPoJo> laydanhsachLoaiTin()
    {
        ArrayList<LoaiTinPoJo> arr = new ArrayList<LoaiTinPoJo>();
        String sql = "SELECT * FROM loaitin";
        DataProvider dp = new DataProvider();
        dp.open();
        
        try{
            ResultSet rs = dp.executeQuery(sql);
            while (rs.next()){
                LoaiTinPoJo loaitin= new LoaiTinPoJo();
               loaitin.setidLoaiTin(rs.getInt("idLoaiTin"));
               loaitin.setTenLoaiTin(rs.getString("tenLoaiTin"));
                arr.add(loaitin);
            }            
        }
        catch(SQLException ex){
            System.out.println(ex.getMessage());                       
        }
        dp.close();
        return arr;
    }
    
}
